# coding:utf8

import MySQLdb

# 获取连接
conn = MySQLdb.connect(host='127.0.0.1', user='root', passwd='123456', charset='utf8', db='test')

# 获取普通游标 
cursor = conn.cursor()

# 查询SQL
sql = "select * from article_innodb;"
cursor.execute(sql)

rs = cursor.fetchall()
for row in rs:
    # 普通游标返回结果是元祖，需要使用位置索引来访问数据
    print row[0], row[1], row[2], row[3]

# 打印列头
print cursor.description

# 关闭游标
cursor.close()
# 关闭连接
conn.close()
